<!doctype html>
<html lang="en">

	<head>
		<meta charset="UTF-8" />
		<title>添加新地址</title>
		<meta charset="UTF-8">
		<meta name="ali-app-title-content" content="e6a9" />
		<meta name="ali-app-title-color" content="#dd2727" />
		<meta name="aplus-terminal" content="1" />
		<meta name="apple-mobile-web-app-title" content="TMALL" />
		<meta name="apple-mobile-web-app-capable" content="yes" />
		<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
		<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" />
		<meta name="spm-id" content="a3204.7152233">
		<meta name="format-detection" content="telephone=no, address=no">
		<title>天猫超市 </title>
		<link rel="shortcut icon" type="image/x-icon" href="img/favicon.ico" />
		<link rel="stylesheet" type="text/css" href="css/svg/font.css" />
		<link rel="stylesheet" type="text/css" href="css/guanlishouhuodizhi.css" />
		<script src="js/jquery-1.11.2.js"></script>

	</head>

	<body>
		<yj>
			<div class="pa-a" id="zk-a">
			</div>
			<div class="pa-a2" id="zk-h"><span></span><samp id="pa-a">确定</samp></div>

			<div class="top">
				<span class="left">
				<samp id="hui"><</samp> 添加新地址
			</span>
				<a id="bao">保存</a>
			</div>
			<content>
				<p>收货人:<input type="text" placeholder="请输入收货人姓名" id="text" /></p>
				<p>联系电话：<input type="tel" placeholder="请输入手机号" id="tel" /></p>
				<p>所在地区<input type="text" placeholder="请输入所在地区" id="suo" /></p>
				<p>街道<input type="text" placeholder="请输入所在街道" id="jie" /></p>
				<input type="text" placeholder="详细地址" id="mo" />
				<p>设为默认地址 <input type="checkbox" style="float: right; margin-top: 5%; width: .6rem; height: .6rem;" /></p>
			</content>
		</yj>
		<script>
			document.documentElement.style.fontSize = innerWidth / 16 + 'px';
			onresize = function() {
				document.documentElement.style.fontSize = innerWidth / 16 + 'px'
			}
			$("#tel").blur(function() {
				var ze = /^(1)[3|4|5|7|8](\d){9}$/;
				var hh = document.getElementById('tel').value;
				if(hh.match(ze)) {} else {
					$("#zk-a").show();
					$("#zk-h").show();
					$("#zk-h span").text('联系电话格式不正确')
				}
			})

			hui.addEventListener("click", fn1, false);

			function fn1() {
				window.location.href = "guanlishouhuodizhi.html";
			}
			$("#bao").click(function() {
				var txt = $("#text").val();
				var tel = $("#tel").val();
				var suo = $("#suo").val();
				var jie = $("#jie").val();
				var mo = $("#mo").val();
				var ze = /^(1)[3|4|5|7|8](\d){9}$/;
				if(txt == "" && tel == "" && suo == "" && jie == "" && mo == "") {
					$("#zk-a").show();
					$("#zk-h").show();
					$("#zk-h span").text('请将修改资料填写完整');

				} else {
					if(tel.match(ze)) {

						localStorage.dizhi = txt + "-" + tel + "-" + suo + jie + mo;
						$.ajax({
							type: "get",
							url: "http://192.168.1.100/supermarket/data/user_update_addr.php",
							async: true,
							data: {
								'user_addr': localStorage.dizhi,
								'user_phone': localStorage.user_phone
							},
							dataType: "jsonp",
							jsop: "callback",
							jsonpCallback: "success_JsonpCallback",
							success: function(e) {
								if(e == "success") {
									window.location.href = "guanlishouhuodizhi.html"
								} else {
									$("#zk-a").show();
									$("#zk-h").show();
									$("#zk-h span").text("提交信息失败，请先登录");
									window.location.href = "denglu.html"
								}
							}
						})
					} else {
						$("#zk-a").show();
						$("#zk-h").show();
						$("#zk-h span").text('手机号码格式不对');
					}
				}
			})

			var ze = document.getElementById('pa-a')
			ze.addEventListener('click', fn, false)

			function fn() {
				$("#zk-a").hide();
				$("#zk-h").hide();

			}
		</script>
	</body>

</html>